package com.eet.excel.model;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 订单导出Excel
 *
 * @author Administrator
 */
@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "tb_order")
public class OrderModel {

    /**
     * 订单ID
     */
    @Id
    @GeneratedValue(generator = "orderGenerator")
    @GenericGenerator(name = "orderGenerator", strategy = "uuid")
    @ExcelIgnore
    private String id;

    /**
     * 产生订单的用户
     */
    @Column(name = "order_amount")
    @ExcelProperty(value = {"订单数量"}, index = 0)
    private Integer orderAmount;

    /**
     * 订单流水
     */
    @Column(name = "flow_num", length = 50)
    @ExcelProperty(value = {"订单流水号"}, index = 1)
    private String flowNum;

    /**
     * 订单金额
     */
    @Column
    @ExcelProperty(value = {"金额"}, index = 2)
    private BigDecimal price;

    /**
     * create_time
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time")
    @CreationTimestamp
    @ExcelIgnore
    private Date createTime;

    /**
     * 更新时间
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time")
    @UpdateTimestamp
    @ExcelIgnore
    private Date updateTime;

    /**
     * 订单描述
     */
    @Column(columnDefinition = "TEXT", length = 512)
    @ExcelProperty(value = {"订单描述"}, index = 3)
    private String description;
}
